package com.cn.ant.modules.sys.utils;

import com.cn.ant.common.utils.CacheUtils;
import com.cn.ant.common.utils.SpringContextHolder;
import com.cn.ant.modules.school.dao.MajorInfoDao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * ClassName:SchoolUtils
 * Function:学校工具类
 * Date: 2015/10/23 19:01
 *
 * @author huanggenhua
 * @version 1.0
 * @since JDK 1.6
 */
public class SchoolUtils {

    private static String MAJOR_TYPE_CACHE = "majorTypeList";
    private static MajorInfoDao majorInfoDao = SpringContextHolder.getBean(MajorInfoDao.class);


    /**
     * 获取专业类型
     *
     * @return
     */
    public static List<Map<String, String>> getMajorType(String batchLevel) {
        List<Map<String, String>> majorTypeList = (List<Map<String, String>>) CacheUtils.get(MAJOR_TYPE_CACHE);
        if (majorTypeList == null) {
            //查询专业大类与专业类型的关系
            Map<String, String> params = new HashMap<>();
            params.put("batchLevel", batchLevel);
            majorTypeList = majorInfoDao.queryMajorType(params);
            CacheUtils.put(MAJOR_TYPE_CACHE, majorTypeList);
        }
        return majorTypeList;
    }

}
